package com.rimi.Task;

import com.rimi.cache.VideoCache;
import com.rimi.dao.VideoDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class VideoCacheTask {
    @Autowired
    private VideoDao vd;
    @Autowired
    private VideoCache vc;

    @Scheduled(cron = "0/10 * * * * ?")
    public void addVideoToMysql(){
        for (int i = 1; i < 100; i++) {
            if(vc.getVideoByIdFromCache(i)==null){
                return;
            }
            vd.updateHot(vc.getVideoByIdFromCache(i));
        }
    }
}
